//
//  OrderViewController.m
//  XingRun
//
//  Created by 赵颜彬 on 17/1/12.
//  Copyright © 2017年 赵颜彬. All rights reserved.
//

#import "OrderViewController.h"
#import "SaleHouseToolBar.h"
@interface OrderViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@property(nonatomic, strong)NSArray *dataArr;

@property (nonatomic, strong)  SaleHouseToolBar *bar;


@end

@implementation OrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"订单确定";
    
    self.dataArr = @[@"联系人信息",@"星运动积分商城"];
    [self cretableView];
    
    [self createToolBar];
}

- (void)createToolBar{
    _bar = [SaleHouseToolBar new];
    [_bar addContactTarget:self Action:@selector(chat:)];
    [_bar.share setTitle:@"总合计: 200黑豆" forState:UIControlStateNormal];
    [_bar.contact setTitle:@"确认兑换" forState:UIControlStateNormal];
    [self.view addSubview:_bar];
    
    _bar.frame = CGRectMake(0, self.view.bounds.size.height - 50 * HEIGHT, 375 * WIDTH, 50 * HEIGHT);
}
-(void)chat:(UIButton *)btn{
    
}
-(void)cretableView{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, -29, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStyleGrouped];
    self.tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_tableView];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        OrderTableViewCell  *cell= [[OrderTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell1"];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;//设置
        return cell;
    }if (indexPath.section == 1) {
        OrderNextTableViewCell *cell = [[OrderNextTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell2"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    return [[UITableViewCell alloc]init];
    
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 100 *HEIGHT;
    }if (indexPath.section == 1) {
        return 450 * HEIGHT;
    }
    return 250 * HEIGHT;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return _dataArr[0];
    }else{
        return _dataArr[1];
    }
}

//点
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        AddressViewController *vc = [[AddressViewController alloc] init];
        vc.hidesBottomBarWhenPushed=YES;// 进入后隐藏tabbar
        [self.navigationController pushViewController:vc animated:YES];
    }
   
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
